{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "import pydicom\n",
    "import pandas as pd\n",
    "import matplotlib.pyplot as plt\n",
    "import matplotlib.animation as animation\n",
    "import ipywidgets as widgets\n",
    "import nibabel as nib\n",
    "import numpy as np\n",
    "import pyarrow.parquet as pq\n",
    "\n",
    "from IPython.display import HTML\n",
    "from tqdm import tqdm\n",
    "from totalsegmentator.python_api import totalsegmentator\n",
    "\n",
    "# totalsegmentator(input_path, output_path)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Data shape: (512, 512, 1022)\n",
      "<class 'nibabel.nifti1.Nifti1Header'> object, endian='<'\n",
      "sizeof_hdr      : 348\n",
      "data_type       : b''\n",
      "db_name         : b''\n",
      "extents         : 16384\n",
      "session_error   : 0\n",
      "regular         : b'r'\n",
      "dim_info        : 0\n",
      "dim             : [   3  512  512 1022    1    1    1    1]\n",
      "intent_p1       : 0.0\n",
      "intent_p2       : 0.0\n",
      "intent_p3       : 0.0\n",
      "intent_code     : none\n",
      "datatype        : float32\n",
      "bitpix          : 32\n",
      "slice_start     : 0\n",
      "pixdim          : [-1.          0.89453125  0.89453125  0.5         0.          0.\n",
      "  0.          0.        ]\n",
      "vox_offset      : 0.0\n",
      "scl_slope       : nan\n",
      "scl_inter       : nan\n",
      "slice_end       : 0\n",
      "slice_code      : unknown\n",
      "xyzt_units      : 10\n",
      "cal_max         : 0.0\n",
      "cal_min         : 0.0\n",
      "slice_duration  : 0.0\n",
      "toffset         : 0.0\n",
      "glmax           : 0\n",
      "glmin           : 0\n",
      "descrip         : b'2203.6-dirty 2022-09-08T15:38:56+01:00'\n",
      "aux_file        : b''\n",
      "qform_code      : scanner\n",
      "sform_code      : unknown\n",
      "quatern_b       : 0.0\n",
      "quatern_c       : 1.0\n",
      "quatern_d       : 0.0\n",
      "qoffset_x       : 240.55273\n",
      "qoffset_y       : -79.052734\n",
      "qoffset_z       : -1696.9\n",
      "srow_x          : [0. 0. 0. 0.]\n",
      "srow_y          : [0. 0. 0. 0.]\n",
      "srow_z          : [0. 0. 0. 0.]\n",
      "intent_name     : b''\n",
      "magic           : b'n+1'\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "<matplotlib.image.AxesImage at 0x7f790bb32450>"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAa4AAAGdCAYAAABKG5eZAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjcuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/bCgiHAAAACXBIWXMAAA9hAAAPYQGoP6dpAAAwWklEQVR4nO3df3RU5YH/8U9CSCAkkwiSGRN+lB5FiBqwUGG21K9KlqjBHzWeWg6HsEoIZYMVUNZmVRDdbjy6R9Q9iIQoaLdCtSxSg1JpFFhqoBJhQRTQLmtg4iSsHpKATYDkfv9IZ2QgQOb3PMn7dc4cydx75z73gvPJ89znR5xlWZYAADBEfLQLAACAPwguAIBRCC4AgFEILgCAUQguAIBRCC4AgFEILgCAUQguAIBREqJdgEC0t7errq5OqampiouLi3ZxAAB+sixLzc3NyszMVHy8f3UoI4Orrq5OgwcPjnYxAABBOnz4sAYNGuTXMUYGV2pqqiTpowyHUvxMagBA9B1vb9cPG9ze73N/GBlcnubBlPh4pRJcAGCsQB738K0PADCKX8H1+OOPKy4uzuc1YsQI7/aWlhaVlJRowIABSklJUUFBgerr630+o7a2Vvn5+UpOTlZGRoYWLFig06dPh+ZqAADdnt9NhVdddZX++Mc/fvcBCd99xLx587Rhwwa9+eabSktL05w5c3TXXXfpT3/6kySpra1N+fn5cjgc+vDDD/XVV1+psLBQvXv31r/+67+G4HIAAN2d38GVkJAgh8NxzvuNjY16+eWX9frrr+umm26SJK1cuVIjR47U9u3bN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FEILgCAUQguAIBRCC4AgFEILgCAUQguAIBRCC4AgFEILgCAUQguAIBRCC4AgFEILgCAUQguAIBRCC4AgFEILgCAUQguAIBRCC4AgFEILgCAUQguAIBRCC4AgFEILgCAUQguAIBRCC4AgFEILgCAUQguAIBRCC4AgFEILgCAUQguAIBRCC4AgFEILgCAUQguAIBRCC4AgFEILgCAUQguAIBRCC4AgFEILgCAUQguAIBRCC4AgFEILgCAUQguAIBRCC4AgFEILgCAUQguAIBRCC4AgFEILgCAUfwOrq1bt+q2225TZmam4uLi9NZbb/lstyxLCxcu1GWXXaa+ffsqNzdXn3/+uc8+33zzjaZOnSqbzab09HTNmDFDx48fD+pCAAA9g9/BdeLECY0aNUpLly7tdPvTTz+tF154QS+99JJ27Nihfv36KS8vTy0tLd59pk6dqn379mnTpk2qrKzU1q1bVVxcHPhVAAB6jDjLsqyAD46L07p163TnnXdK6qhtZWZm6sEHH9RDDz0kSWpsbJTdbteqVav0s5/9TJ999pmys7P10UcfaezYsZKkjRs36tZbb9WRI0eUmZl50fM2NTUpLS1NnzkylRpPaycAmKa5vV0j3XVqbGyUzWbz69iQfusfOnRIbrdbubm53vfS0tI0btw4VVdXS5Kqq6uVnp7uDS1Jys3NVXx8vHbs2NHp57a2tqqpqcnnBQDomUIaXG63W5Jkt9t93rfb7d5tbrdbGRkZPtsTEhLUv39/7z5nKysrU1pamvc1ePDgUBYbAGAQI9rZSktL1djY6H0dPnw42kUCAERJSIPL4XBIkurr633er6+v925zOBxqaGjw2X769Gl988033n3OlpSUJJvN5vMCAPRMIQ2uYcOGyeFwqKqqyvteU1OTduzYIafTKUlyOp06duyYampqvPu8//77am9v17hx40JZHABAN5Tg7wHHjx/XF1984f350KFD2r17t/r3768hQ4Zo7ty5+pd/+RddccUVGjZsmB577DFlZmZ6ex6OHDlSN998s2bOnKmXXnpJp06d0pw5c/Szn/2sSz0KAQA9m9/BtXPnTt14443en+fPny9Jmj59ulatWqV/+qd/0okTJ1RcXKxjx45pwoQJ2r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dRqaGiwLCuy98a44LIsy/r3f/93a8iQIVZiYqJ13XXXWdu3b492kSLigw8+sCSd85o+fbplWR1d4h977DHLbrdbSUlJ1sSJE60DBw74fMbXX39tTZkyxUpJSbFsNpt17733Ws3NzVG4mtDr7N5IslauXOnd569//av1j//4j9Yll1xiJScnWz/5yU+sr776yudz/vd//9e65ZZbrL59+1qXXnqp9eCDD1qnTp2K8NWE3n333WcNHTrUSkxMtAYOHGhNnDjRG1qW1bPvzfmcHVw9+R7dc8891mWXXWYlJiZaWVlZ1j333GN98cUX3u2RvDcsawIAMIpRz7gAACC4AABGIbgAAEYhuAAARiG4AABGIbgAAEYhuAAARiG4AABGIbgAAEYhuAAARiG4AABGIbgAAEb5/5T3jDRej+tdAAAAAElFTkSuQmCC",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "nifti_file = 'dataset/segmentations/21057.nii'\n",
    "img = nib.load(nifti_file)\n",
    "segmentation_data = img.get_fdata()\n",
    "header = img.header\n",
    "\n",
    "# Display the shape of the data\n",
    "print(\"Data shape:\", segmentation_data.shape)\n",
    "\n",
    "# Display header information (metadata)\n",
    "print(header)\n",
    "segmentation_data.shape\n",
    "plt.imshow(segmentation_data[:,:,400].T, cmap=\"Set1\", origin=\"lower\") "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "-1000000000000.0"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "-1e12"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "import cv2\n",
    "import numpy as np\n",
    "H=np.array([[ 5.62821190e-01, -7.36083208e-01,  6.69177497e+01],\n",
    "       [-1.11745945e-02,  7.34279355e-02,  4.36816920e+01],\n",
    "       [-1.65641696e-05, -1.23659591e-03,  1.00000000e+00]])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 5.62821190e-01, -7.36083208e-01,  6.69177497e+01],\n",
       "       [-1.11745945e-02,  7.34279355e-02,  4.36816920e+01],\n",
       "       [-1.65641696e-05, -1.23659591e-03,  1.00000000e+00]])"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "H"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "bop",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.0"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
